package com.ddwl.schema.bo.order;

import com.ddwl.schema.bo.base.BaseBo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import javax.validation.Valid;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.math.BigDecimal;
import java.util.List;

/**
 * 类CreateOrderBo.java的实现描述：创建订单入参
 *
 * @author zach
 * @Date :2020-05-29 09:40.
 */
@Getter
@Setter
@ApiModel("创建订单入参")
public class CreateOrderBo extends BaseBo {

    @ApiModelProperty("用户收货地址ID")
    private String userAdderId;

    @Valid
    @NotNull(message = "商品信息不能为空")
    @Size(min = 1, message = "最少购买一个商品")
    @Size(max = 20, message = "最多一次性购买20个商品")
    @ApiModelProperty(value = "订单商品信息", required = true)
    private List<SkuList> skuLists;

    @ApiModelProperty(value = "来源信息(推广的时候用)")
    private String source;

    @ApiModelProperty(value = "是否购物车订单0不是1是")
    private Integer isShoppingCart;

    @Min(value = 0, message = "商品总价不能小于0")
    @ApiModelProperty(value = "商品总价", required = true)
    private BigDecimal price;

    @Min(value = 1, message = "购物津贴抵扣金额不能小于1")
    @ApiModelProperty(value = "购物津贴抵扣金额")
    private BigDecimal subsidyPrice;

    @ApiModelProperty(value = "主订单id", hidden = true)
    private String masterOrderId;

    @ApiModelProperty(value = "订单备注")
    private String note;

    @ApiModelProperty(value = "订单类型 (0普通订单 1秒杀单 2砍价单 3限时购)", hidden = true)
    private Integer orderType = 0;

    @ApiModelProperty(value = "总邮费")
    private BigDecimal totalFare;

    @ApiModelProperty(value = "代理商品当前门店ID 用作分佣")
    private String agentShopId;

    @ApiModelProperty(value = "用户优惠券ID")
    private List<String> userCouponIds;

    @Data
    @ApiModel("订单商品信息")
    public static class SkuList {

        @ApiModelProperty(value = "商品id", required = true)
        private String itemId;

        @NotNull(message = "商品规格id不能为空")
        @ApiModelProperty(value = "商品规格id", required = true)
        private String skuId;

        @Min(value = 1, message = "商品最少购买一件")
        @NotNull(message = "购买数量不能为空")
        @ApiModelProperty(value = "购买数量", required = true)
        private Integer skuQty;

        @ApiModelProperty("0快递1外送2自提默认快递")
        private Integer deliveryType;

        @ApiModelProperty(value = "备注")
        private String remark;

        @ApiModelProperty("用户收货地址ID")
        private String userAdderId;

        @Size(max = 15, message = "电话长度过长")
        @ApiModelProperty("自提用户联系电话")
        private String userMobile;

        @ApiModelProperty(value = "参与的活动id")
        private String activityId;

        @ApiModelProperty(value = "是否公益商品 0否 1是")
        private Integer charityFlag = 0;

        @ApiModelProperty(value = "是否代理商品 0否 1是")
        private Integer agentFlag = 0;

    }
}

